﻿define(['util', 'ajax'], function (util, ajax) {
    "use strict";

    var exports = {},
         ViewModel;

    ViewModel = function (data) {        
        var self = this;        
        var leadDetail = data.detail;
        
        var canvas = document.getElementById("imgCanvas");
        util.image.drawImage(canvas, leadDetail.imageData);

        self.id = ko.observable(leadDetail.id);
        self.name = ko.observable(leadDetail.name);        
        self.email = ko.observable(leadDetail.email);
        self.companyName = ko.observable(leadDetail.companyName);       
        self.phone = ko.observable(leadDetail.phone);
        self.description = ko.observable(leadDetail.description);               
    };

    exports.exec = function (sectionId, model) {
        var viewModel = new ViewModel(model);
        ko.applyBindings(viewModel, document.getElementById(sectionId));
    };

    return exports;
});